#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

vector<vector<int>> modifiedMatrix(vector<vector<int>>& matrix) {
    int n = matrix.size(), m = matrix[0].size();
    for (int j = 0; j < m; j++)
    {
        int nmax = 0;
        for (int i = 0; i < n; i++)    nmax = max(nmax, matrix[i][j]);
        for (int i = 0; i < n; i++)
            if (matrix[i][j] == -1)
                matrix[i][j] = nmax;
    }
    return matrix;
}